package com.wc.alorithm_blue_bridge._二分.植物保留;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/6/30 0:43
 * @description https://www.lanqiao.cn/problems/19678/learning/?contest_id=193
 */
public class Main {
    /**
     * 状态机模型+二分
     * 思路：
     * 种与不种的问题, 种就前面a[i] - m之间不能种了, 不种就是前面的种或者不种的最大值,
     * 如何寻找a[i] - m 不种的呢, 因为前面的有序的,那就可以二分了
     * 思路清晰, 开始AC
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] a = new int[N];
    // f[i][0] 表示这个不种, f[i][1] 表示这个种
    static int[][] f = new int[N][2];
    static int n, m;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        a[0] = -(int) 2e9;
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            f[i][0] = Math.max(f[i - 1][0], f[i - 1][1]);
            int l = 0, r = i - 1;
            while (l < r) {
                int mid = l + r + 1 >> 1;
                if (a[mid] <= a[i] - m) l = mid;
                else r = mid - 1;
            }
            f[i][1] = Math.max(f[l][1], f[l][0]) + 1;
        }
        out.println(Math.max(f[n][0], f[n][1]));
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
